var express = require('express');
var router = express.Router();
const {Course,User,Category} = require('../models');
const { where } = require('sequelize');
const { failure, success } = require('../utils/response');

// 前台接口，此接口为分类页面
router.get('/', async function(req, res, next) {
  try {
    const categories = await Category.findAll({
        order:[['rank','ASC'],['id','DESC']] //ASC升序，DESC降序
    })
    success(res,'查询分类成功',{categories})
  } catch (error) {
    failure(res,error)
  }
});

module.exports = router;
